/*
 * Created on Mar 5, 2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package com.scalar.chiptrack.sales;

import com.scalar.chiptrack.utils.StringUtils;
import java.io.Serializable;

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class ContactPerson implements Serializable
{
	private String contactPerson = null;
	private String phoneNumber = null;
	private String faxNumber = null;
	private String email = null;
	private String cellNumber = null;
	private String address = null;
	boolean disabled = false;
	boolean isChecked = false;
    //added by varma(24jun2004)
    private boolean salesAckMail = false;
    private boolean shipAlerts = false;
    private boolean proformaInvoice = false;
    private boolean packingSlip = false;
    private boolean commerInvoice = false;
    private boolean quoteAckMail = false;
    private String  contactPersonType = null;
    private boolean rmaAckMail = false;


	public ContactPerson() {
	}

	 public boolean getDisabled() {
		return disabled;
	}

	public void setDisabled (boolean disabled) {
	   this.disabled = disabled;
	}
	public boolean getIsChecked() {
		return isChecked;
	}

	public void setIsChecked (boolean isChecked) {
	   this.isChecked = isChecked;
	}

	  public String getContactPerson() {
			   return contactPerson;
	}
	public String getAddress() 
	{
	   if(address == null)
	   address = "";
	   return address;
	}

	public void setAddress(String address) 
	{
	   this.address = address;
	}


	 public String getEncodeContactPerson ()
	 {
		String encodeContactPerson = null;
		if(contactPerson != null)
		{
			encodeContactPerson = StringUtils.encodeAllSpecialCharacters(contactPerson);
		}
		return encodeContactPerson;
	}

	public void setContactPerson (String contactPerson) {
	   this.contactPerson = contactPerson;
	}
	
	public String getPhoneNumber()
	{
		if(phoneNumber == null)
		phoneNumber = "";
		return phoneNumber;
	}
	public void setPhoneNumber(String phoneNumber)
	{
	   this.phoneNumber = phoneNumber;
	}
	public String getFaxNumber()
	{
		if(faxNumber == null)
		faxNumber = "";
		return faxNumber;
	}
	public void setFaxNumber(String faxNumber)
	{
		this.faxNumber = faxNumber;
	}
	public String getEmail()
    {
	    if(email == null)
		email = "";
	    return email;
    }
	public void setEmail(String email)
	{
		this.email = email;
	}
 	public String getCellNumber() 
	{
		if(cellNumber == null)
		cellNumber = "";
	  	return cellNumber;
	}

	public void setCellNumber(String cellNumber) 
	{
		this.cellNumber = cellNumber;
	}
    //Added by varma(24jun2004)
   public boolean getSalesAckMail()
   {
       return salesAckMail;
   }
   public void setSalesAckMail(boolean salesAckMail)
   {
       this.salesAckMail = salesAckMail;
   }
   public boolean getShipAlerts()
   {
       return shipAlerts;
   }
   public void setShipAlerts(boolean shipAlerts)
   {
       this.shipAlerts = shipAlerts;
   }
   public boolean getProformaInvoice()
   {
       return proformaInvoice;
   }
   public void setProformaInvoice(boolean proformaInvoice)
   {
       this.proformaInvoice = proformaInvoice;
   }
   public boolean getPackingSlip()
   {
       return packingSlip;
   }
   public void setPackingSlip(boolean packingSlip)
   {
       this.packingSlip = packingSlip;
   }

   public boolean getCommerInvoice()
   {
       return commerInvoice;
   }
   public void setCommerInvoice(boolean commerInvoice)
   {
       this.commerInvoice = commerInvoice;
   }


    public boolean isQuoteAckMail() {
        return quoteAckMail;
    }

    public void setQuoteAckMail(boolean quoteAckMail) {
        this.quoteAckMail = quoteAckMail;
    }

    public String getContactPersonType() {
        return contactPersonType;
    }

    public void setContactPersonType(String contactPersonType) {
        this.contactPersonType = contactPersonType;
    }


    public boolean isRmaAckMail() {
        return rmaAckMail;
    }

    public void setRmaAckMail(boolean rmaAckMail) {
        this.rmaAckMail = rmaAckMail;
    }//Added by Rohan on June 3rd 2004
    /**
     * This method will format the contents of the contact person object such that
     * they can be inserted in the CT database
     *
     */
    public void formatForInsertingIntoCT()
    {
        if( this.getContactPerson() == null )
        {
            this.setContactPerson( "" );
        }
        else
        {
            this.setContactPerson( this.getContactPerson().trim() );
        }

        if( this.getContactPerson().length() > 50 )
        {
            this.setContactPerson( this.getContactPerson().substring( 0, 49 ) );
        }

        if( this.getCellNumber() == null )
        {
            this.setCellNumber( "" );
        }
        else
        {
            this.setCellNumber( this.getCellNumber().trim() );
        }

        if( this.getCellNumber().length() > 50 )
        {
            this.setCellNumber( this.getCellNumber().substring( 0, 49 ) );
        }

        if( this.getPhoneNumber() == null )
        {
            this.setPhoneNumber( "" );
        }
        else
        {
            this.setPhoneNumber( this.getPhoneNumber().trim() );
        }

        if( this.getPhoneNumber().length() > 50 )
        {
            this.setPhoneNumber( this.getPhoneNumber().substring( 0, 49 ) );
        }

        if( this.getFaxNumber() == null )
        {
            this.setFaxNumber( "" );
        }
        else
        {
            this.setFaxNumber( this.getFaxNumber().trim() );
        }

        if( this.getFaxNumber().length() > 50 )
        {
            this.setFaxNumber( this.getFaxNumber().substring( 0, 49 ) );
        }

        if( this.getEmail() == null )
        {
            this.setEmail( "" );
        }
        else
        {
            this.setEmail( this.getEmail().trim() );
        }

        if( this.getEmail().length() > 50 )
        {
            this.setEmail( this.getEmail().substring( 0, 49 ) );
        }
    }

    //Added by Rohan on June 3rd 2004
    /**
     * Returns if the address object is empty. Presently comparing only the
     * following fields, if required add the other fields also
     *
     * <li> Contact Person
     * <li> Cell Number
     * <li> Phone Number
     * <li> Fax Number
     * <li> Email
     *
     * @return boolean value indication if the address if empty
     */
    public boolean isContactPersonEmpty()
    {
        if( ( "".equals( this.getContactPerson() ) ) && ( "".equals( this.getPhoneNumber() ) ) &&
            ( "".equals( this.getCellNumber() )    ) && ( "".equals( this.getFaxNumber() ) ) &&
            ( "".equals( this.getEmail() )         ) )
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public void prepareContactPersonForGpInsertion()
    {
        if( this.getContactPerson() == null )
        {
            this.setContactPerson( "" );
        }
        else if( this.getContactPerson().trim().length() > 31 )
        {
            this.setContactPerson( this.getContactPerson().trim().substring( 0, 30 ) );
        }

        if( this.getPhoneNumber() == null )
        {
            this.setPhoneNumber( "" );
        }
        else if( this.getPhoneNumber().trim().length() > 21 )
        {
            this.setPhoneNumber( this.getPhoneNumber().trim().substring( 0, 20 ) );
        }

        if( this.getFaxNumber() == null )
        {
            this.setFaxNumber( "" );
        }
        else if( this.getFaxNumber().trim().length() > 21 )
        {
            this.setFaxNumber( this.getFaxNumber().trim().substring( 0, 20 ) );
        }

        if( this.getEmail() == null )
        {
            this.setEmail( "" );
        }
        else if( this.getEmail().trim().length() > 201 )
        {
            this.setEmail( this.getEmail().trim().substring( 0, 200 ) );
        }
    }

    public String toString()
    {
        StringBuffer sb = new StringBuffer();

        sb.append("-------------------ContactPerson-------------------");
        sb.append("[isChecked  = " + isChecked + " ]");
        sb.append("[contactPerson     = " + contactPerson + " ]");
        sb.append("[contactPersonType = " + contactPersonType + " ]");
        sb.append("[email             = " + email + " ]\n");
        /*sb.append("[salesAckMail      = " + salesAckMail + " ]");
        sb.append("[quoteAckMail      = " + quoteAckMail + " ]");
        sb.append("[packingSlip       = " + packingSlip + " ]");
        sb.append("[commerInvoice     = " + commerInvoice + " ]");
        sb.append("[proformaInvoice   = " + proformaInvoice + " ]\n");*/

        return sb.toString();
    }
}
	
	
	